﻿<AddDataFormTemplateSpec 
	xmlns="bb_appfx_adddataformtemplate"
	xmlns:c="bb_appfx_commontypes" 
	ID="429fb40a-c7ce-4d10-926b-3c865eba549d" 
	Name="Stewardship Plan Add Data Form Extension"
	Description="Extends the OOB Stewardship Add form to include Designation for the TDSM datalist" 
	Author="Blackbaud Professional Services"
	DataFormInstanceID="18423c96-861e-49e5-b9b3-af662d994688" 
	RecordType="Stewardship Plan"
    c:SecurityUIFolder="TDSM"
	>

	<SPDataForm>
		<SaveImplementation SPName="USP_DATAFORMTEMPLATE_ADD_STEWARDSHIPPLAN_EXTENSION">
			<c:CreateProcedureSQL>
				<![CDATA[
create procedure dbo.USP_DATAFORMTEMPLATE_ADD_STEWARDSHIPPLAN_EXTENSION
(
  @ID uniqueidentifier = null output
 ,@CONTEXTID uniqueidentifier
 ,@CHANGEAGENTID uniqueidentifier = null
 ,@DESIGNATIONID uniqueidentifier = null
)
as

set nocount on;

set @ID = isnull(@id,newid());

if @CHANGEAGENTID is null begin
  exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;
end;

declare @CURRENTDATE datetime = getdate();

begin try
  insert into dbo.USR_STEWARDSHIPPLAN(ID,DESIGNATIONID,DATEADDED,ADDEDBYID,CHANGEDBYID)
  values(@CONTEXTID, @DESIGNATIONID,@CURRENTDATE,@CHANGEAGENTID,@CHANGEAGENTID);
end try
begin catch
  exec dbo.USP_RAISE_ERROR
  return 1
end catch

return 0;
]]>
			</c:CreateProcedureSQL>
		</SaveImplementation>
	</SPDataForm>
    
    <Context ContextRecordType="Stewardship Plan" RecordIDParameter="CONTEXTID"/>
    
	<c:FormMetaData FixedDialog="true">
		<c:FormFields>
            <c:FormField FieldID="DESIGNATIONID" DataType="Guid" Caption="Designation" CaptionResourceKey="$$designation">
                <c:SearchList SearchListID="3187706b-b1ee-410f-b599-27aee1b26237" EnableQuickFind="true" />
            </c:FormField>
		</c:FormFields>
	</c:FormMetaData>

    <c:DataFormExtension DataFormInstanceID="DCFD8DF9-E0B6-4386-B93A-337B9F637230" RenderStyle="Tab" TabCaption="Designation"/>

</AddDataFormTemplateSpec>